package com.situ.day13Lianxi;

import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

public class Test {
	public static void main(String[] args) {
		JFrame jf = new JFrame();
		jf.setSize(400, 800);    //窗口大小
		jf.setLocation(400,100);  //距离左上坐标位置
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置默认退出
		jf.setVisible(true);   //显示在界面上
//		jf.setResizable(false);//固定窗口
		
		JPanel panel = new JPanel();//设置容器
		jf.add(panel);
		
		panel.setLayout(new GridLayout(7, 1));//容器布局
		//用户名
		JPanel yongHuPanen = new JPanel();
		JLabel mingLabel = new JLabel("用户名");
		JTextField mingTextField = new JTextField(10);
		yongHuPanen.add(mingLabel);
		yongHuPanen.add(mingTextField);
		panel.add(yongHuPanen);
		//密码
		JPanel miMaPanel = new JPanel();
		JLabel miLabel = new JLabel("密码");
		JTextField miTextField = new JTextField(10);
		miMaPanel.add(miLabel);
		miMaPanel.add(miTextField);
		panel.add(miMaPanel);
		//性别
		JPanel xingBiePanel = new JPanel();
		JLabel xingBieLabel = new JLabel("性别");
		JRadioButton manRadioButton = new JRadioButton("男");
		JRadioButton WoManRadionButton = new JRadioButton("女");
		ButtonGroup buttonGroup = new ButtonGroup();
		buttonGroup.add(manRadioButton);
		buttonGroup.add(WoManRadionButton);
		xingBiePanel.add(xingBieLabel);
		xingBiePanel.add(manRadioButton);
		xingBiePanel.add(WoManRadionButton);
//		xingBiePanel.add(buttonGroup);
		panel.add(xingBiePanel);
		
		//复选框
		JPanel aiHaoPanel = new JPanel();
		JLabel aiHaoLabel = new JLabel("爱好");
		JCheckBox yinYueCheckBox = new JCheckBox("音乐");
		JCheckBox movieCheckBox = new JCheckBox("电影");
		JCheckBox gameCheckBox = new JCheckBox("游戏");
		aiHaoPanel.add(aiHaoLabel);
		aiHaoPanel.add(yinYueCheckBox);
		aiHaoPanel.add(movieCheckBox);
		aiHaoPanel.add(gameCheckBox);
		panel.add(aiHaoPanel);
		//城市
		JPanel cityPanel = new JPanel();
		JLabel cityLabel = new JLabel("城市");
		String[] citys = {"北京", "杭州", "上海", "成都"};
		JComboBox list = new JComboBox(citys);
		cityPanel.add(cityLabel);
		cityPanel.add(list);
		panel.add(cityPanel);
		//学习的语言
		JPanel yuYanPanel = new JPanel();
		JLabel yuYanLabel = new JLabel("学习的科目");
		String[] yuYan = {"语文","数学","英语","化学","物理","地理"};
		JList<String> list2 = new JList<>(yuYan);
		list2.setVisibleRowCount(3);         //显示的个数
		JScrollPane scrollPane = new JScrollPane(list2);//滑轮
		yuYanPanel.add(yuYanLabel);
		yuYanPanel.add(scrollPane);
		panel.add(yuYanPanel);
		
		//注册
		JPanel zhuCePanel = new JPanel();
		JButton zhuButton = new JButton("注册");
		JButton ceButton = new JButton("取消");
//		ceButton.setPreferredSize(new Dimension(30, 30));//按钮大小
		zhuCePanel.add(zhuButton);
		zhuCePanel.add(ceButton);
		panel.add(zhuCePanel);
		
	}
}
